package com.sunda.spmsweb.wmscontroller;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.sunda.spmscommon.ResponseResult;
import com.sunda.spmswms.service.IWhsReport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 南沙仓报表 前端控制器
 * </p>
 *
 * @author Kunpeng
 * @since 2021-08-09
 */
@RestController
@Api(tags = "南沙仓报表", description = "南沙仓报表")
@RequestMapping("/nanshareporter")
public class WhsReportController {

    @Autowired
    IWhsReport iWhsReport;

    @RequestMapping("/inHouseDtlExport")
    @ApiOperation(value = "入库明细导出", notes = "入库明细导出" +
            "{\n" +
            "  \"startDate\":\"2021-08-09\",\n" +
            "  \"endDate\":\"2021-08-10\",\n" +
            "  \"goodsType\":\"X\",\n" +
            "  \"werks\":\"CN01\",\n" +
            "  \"whsLocationCode\":\"1061\",\n" +
            "  \"deliveryNoteSap\":\"deliveryNoteSap\"\n" +
            "}", httpMethod = "POST")
    public ResponseResult inHouseDtlExport(@RequestBody JSONObject queryObj) {
        String goodsType = queryObj.getString("goodsType");
        if (StringUtils.isEmpty(goodsType)) {
            return ResponseResult.error("GoodsType is mandatory required");
        }
        return iWhsReport.inHouseDtlExport(queryObj,goodsType);
    }

    @RequestMapping("/outHouseDtlExport")
    @ApiOperation(value = "出库明细导出", notes = "出库明细导出" +
            "{\n" +
            "  \"startDate\":\"2021-08-09\",\n" +
            "  \"endDate\":\"2021-08-10\",\n" +
            "  \"goodsType\":\"X\",\n" +
            "  \"werks\":\"CN01\",\n" +
            "  \"whsLocationCode\":\"1061\",\n" +
            "  \"packageList\":\"packageList\"\n" +
            "}", httpMethod = "POST")
    public ResponseResult outHouseDtlExport(@RequestBody JSONObject queryObj) {
        String goodsType = queryObj.getString("goodsType");
        if (StringUtils.isEmpty(goodsType)) {
            return ResponseResult.error("GoodsType is mandatory required");
        }
        return iWhsReport.outHouseDtlExport(queryObj,goodsType);
    }

    @RequestMapping("/outWHExportM")
    @ApiOperation(value = "按装箱单号或是柜号导出贸易货出库明细", notes ="按装箱单号或是柜号导出贸易货出库明细" +
            "{\n" +
            "  \"cabinetNumber\":\"UETU2463177\",\n" +
            "  \"packageList\":\"PL00038153\"\n" +
            "}", httpMethod = "POST")
    public ResponseResult outWHExportM(@RequestBody JSONObject queryObj) {
        return iWhsReport.outWHExportM(queryObj);
    }

    @RequestMapping("/outWHExportX")
    @ApiOperation(value = "按装箱单号或是柜号导出备件货出库明细", notes ="按装箱单号或是柜号导出备件货出库明细" +
            "{\n" +
            "  \"cabinetNumber\":\"UETU2463177\",\n" +
            "  \"packageList\":\"PL00038153\"\n" +
            "}", httpMethod = "POST")
    public ResponseResult outWHExportX(@RequestBody JSONObject queryObj) {
        return iWhsReport.outWHExportX(queryObj);
    }


    @RequestMapping("/queryBoxInfo")
    @ApiOperation(value = "按照物料编码,需求单号,箱码,包装单号,采购定单号,送货单号,内部交货单号等查询箱码信息", notes ="按照物料编码,需求单号,箱码,包装单号,采购定单号,送货单号,内部交货单号等查询箱码信息" +
            "{\n" +
            "  \"boxNote\":\"\",\n" +
            "  \"demandNo\":\"\",\n" +
            "  \"packageNote\":\"\",\n" +
            "  \"purchaseNo\":\"\",\n" +
            "  \"deliveryNoteSap\":\"\",\n" +
            "  \"srmContractNo\":\"\",\n" +
            "  \"materialNo\":\"\"\n" +
            "}", httpMethod = "POST")
    public ResponseResult queryBoxInfo(@RequestBody JSONObject queryObj) {
        return iWhsReport.queryBoxInfo(queryObj);
    }

}